package com.ysy.mq;

import com.ysy.constant.RocketMqConstant;
import com.ysy.persimmons.common.response.Response;
import com.ysy.service.NoteService;
import jakarta.annotation.Resource;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


/**
 * 删除本地删除
 * topic 主题
 * MessageModel.BROADCASTING 广播模式
 * MessageModel.CLUSTERING 单个消费
 */
@Component
@RocketMQMessageListener(
        consumerGroup = "persimmons_group"
        , topic = RocketMqConstant.TOPIC_DEL_NOTE_LOCAL_CACHE
        , messageModel = MessageModel.BROADCASTING)
public class DelNoteLocalCacheConsumer implements RocketMQListener<String> {

    private static final Logger logger = LoggerFactory.getLogger(DelNoteLocalCacheConsumer.class);

    @Resource
    private NoteService noteService;

    @Override
    public void onMessage(String noteId) {
        logger.info("DEL_NOTE_LOCAL_CACHE-接收到的消息：{}",noteId);
        Response<?> response = noteService.delNoteCache(noteId);
        logger.info("DEL_NOTE_LOCAL_CACHE-result：{}",response);


    }
}
